package it.mp.multitask;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class Setup extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.setup);
		SharedPreferences prefs = getSharedPreferences(Main.SP_OPTIONS,Context.MODE_PRIVATE);
		CheckBox cb=(CheckBox)findViewById(R.id.CB_kill_question);
		cb.setChecked(prefs.getBoolean(Main.KILL_SENZA_CONFERMA, false));
		
		CheckBox cbRunning=(CheckBox)findViewById(R.id.CB_running);
		cbRunning.setChecked(prefs.getBoolean(Main.APP_RUNNING, true));
		CheckBox cbRecently=(CheckBox)findViewById(R.id.CB_recently);
		cbRecently.setChecked(prefs.getBoolean(Main.APP_RECENTLY, true));
				
		cb.setOnCheckedChangeListener(new OnCheckedChangeListener(){
			public void onCheckedChanged(CompoundButton arg0, boolean checked) {
				SharedPreferences prefs = getSharedPreferences(Main.SP_OPTIONS, Context.MODE_PRIVATE);
				SharedPreferences.Editor editor = prefs.edit();
				editor.putBoolean(it.mp.multitask.Main.KILL_SENZA_CONFERMA, checked);
				editor.commit();		
			}			
		});
		
		cbRunning.setOnCheckedChangeListener(new OnCheckedChangeListener(){
			public void onCheckedChanged(CompoundButton arg0, boolean checked) {
				SharedPreferences prefs = getSharedPreferences(Main.SP_OPTIONS, Context.MODE_PRIVATE);
				SharedPreferences.Editor editor = prefs.edit();
				editor.putBoolean(it.mp.multitask.Main.APP_RUNNING, checked);
				editor.commit();		
			}			
		});
		cbRecently.setOnCheckedChangeListener(new OnCheckedChangeListener(){
			public void onCheckedChanged(CompoundButton arg0, boolean checked) {
				SharedPreferences prefs = getSharedPreferences(Main.SP_OPTIONS, Context.MODE_PRIVATE);
				SharedPreferences.Editor editor = prefs.edit();
				editor.putBoolean(it.mp.multitask.Main.APP_RECENTLY, checked);
				editor.commit();		
			}			
		});
	}
}
